<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">
      <tr>
        <td style="width:90px;text-align: right;padding-top: 65px;">基本信息:</td>
        <td>
          <p style="float: left;">
          车牌号：<span id="vehicleNum">
              {{ result.vehicleNum }} </span
          ><br />

            昵称：<span id="nickName">
              {{ result.nickName }} </span
          ><br />

            总金额（单位：元）：<span id="orderAmount">
              {{ result.orderAmount / 100}} </span
          ><br />

            交易类型：<span id="tranType">
              {{ result.tranType }} </span
          ><br />


            创建时间：<span id="createTime">
              {{ result.createTime }} </span
          ><br />

            商品订单号：<span id="outTradeNo">
              {{ result.outTradeNo }} </span
          ><br />
          </p>
        </td>
      </tr>

      <tr>
        <td style="width:90px;text-align: right;padding-top: 70px;">详情:</td>
        <td>
          <p style="float: left;">

            交易提交时间：<span id="orderDate">
              {{ result.orderDate }} </span
          ><br />
            交易过期时间：<span id="endTime">
              {{ result.endTime }} </span
          ><br />
            商品详情：<span id="goodsDetail">
              {{ result.goodsDetail }} </span
          ><br />
            支付成功回显页面：<span id="returnUrl">
              {{ result.returnUrl }} </span
          ><br />

            通知类型：<span id="notifyType">
              {{ result.notifyType }} </span
          ><br />
          </p>
        </td>
      </tr>
      <tr>
        <td style="text-align: center;" colspan="10">
          <a-button type="primary" @click="close">关闭</a-button>
        </td>
      </tr>
    </table>
  </a-modal>
</template>


<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "IcbcAggregatePaymentLogModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },result: {},
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/b2cpaymentpay/icbcAggregatePaymentLog/add",
          edit: "/b2cpaymentpay/icbcAggregatePaymentLog/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        if(record.returnCode === 0)
        {
          record.returnCode ='交易成功'
        }
        else {
          record.returnCode = '交易失败'
        }
        Object.assign(this.result, record)
        this.visible = true
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.close()

        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化

            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })

          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>